package com.kata.chapter9;

/**
 * Created by Solidsnake on 2014/11/26.
 */
public class Main {

    public static void main(String[] args) {

        System.out.println("========使用中国电源插座========");

        Electricity electricity = new ChinaElectricity();
        int docking = electricity.docking();
        int request = electricity.request();

        openComputer(docking, request);

        System.out.println("================================");

        System.out.println("========使用美国电源插座========");

        Electricity electricity2 = new USAElectricity();
        int docking2 = electricity2.docking();
        int request2 = electricity2.request();

        openComputer(docking2, request2);

        System.out.println("================================");


        System.out.println("========使用电流适配器[中国电源插座模式]========");

        Electricity electricity3 = new AdapterElectricity(new ChinaElectricity());
        int docking3 = electricity3.docking();
        int request3 = electricity3.request();

        openComputer(docking3, request3);

        System.out.println("================================");

        System.out.println("========使用电流适配器[美国电源插座模式]========");

        Electricity electricity4 = new AdapterElectricity(new USAElectricity());
        int docking4 = electricity4.docking();
        int request4 = electricity4.request();

        openComputer(docking4, request4);

        System.out.println("================================");

    }

    private static void openComputer(int docking, int request) {
        if(docking != 3) {
            System.out.println("当前插座不符");
            return;
        }
        if(request != 220) {
            System.out.println("电流过低, 能量供给不足, 电脑无法开启");
            return;
        }
        System.out.println("电脑正常工作");



    }
}
